﻿namespace MsForgeReboot.Tests.Modules {
    #region Usings

    using System.Collections.Generic;
    using System.Threading;
    using System.Web;

    using Microsoft.VisualStudio.TestTools.UnitTesting;

    using Moq;

    using MsForgeReboot.Framework.Interfaces;
    using MsForgeReboot.Web.Modules;

    #endregion

    [TestClass]
    public class MessageDeliveryModuleTests {
        #region Fields

        private Mock<IEventService> eventService;

        private Mock<HttpApplication> httpApplication;

        private MessageDeliveryModule target;

        #endregion

        #region Public Methods and Operators

        [TestInitialize]
        public void TestInitialize() {
            this.httpApplication = new Mock<HttpApplication>();
            this.eventService = new Mock<IEventService>();
            this.target = new MessageDeliveryModule(this.eventService.Object);
        }

        [TestMethod]
        public void TimerIsSetToFireAfter10Seconds() {

            this.eventService.Setup(svc => svc.PeekQueue()).Returns(new List<IChannel>());
            
            this.target.Init(this.httpApplication.Object);
            Thread.Sleep(100);

            this.eventService.Verify(svc => svc.PeekQueue(),Times.Once);
        }

        #endregion
    }
}